package springboot.entity;

import lombok.Data;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;

@Data
public class manager {
    public static final Integer workDuration = 9;

    public static final Integer workStartTime = 9 * 3600;

    public static final Integer workEndTime = (9 + workDuration) * 3600;


    //    活跃群数量
    int activeGroupNum;

    //    平均响应时长
    float avgMessage;
    //    平均解决时长
    float avgProblem;

    //    工作区间平均响应时长
    float avgMessageOnWork;
    //    工作区间平均解决时长
    float avgProblemOnWork;

    //    非工作区间平均响应时长
    float avgMessageNotOnWork;
    //    非工作区间平均解决时长
    float avgProblemNotOnWork;

    //    选择部门或者哪个员工
    String engineer;
    //获取几天前至今的时间(过去的某一个点至今的范围)
    public LocalDate someDay(int dayNum) {
        LocalDate localDate = LocalDate.of(2021, 7, 1);
        Date date1 = null;
        Calendar cal = Calendar.getInstance();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        for (int i = 0; i < dayNum; i++) {
            localDate = localDate.plusDays(-i);


            try {
                date1 = df.parse(String.valueOf(localDate));
            } catch (ParseException e) {
                e.printStackTrace();
            }

            assert date1 != null;
            cal.setTime(date1);
        }
        return null;
    }

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    Date date1 = null;
    Calendar cal = Calendar.getInstance();

    public LocalDate someMonth(int monthNum) {
        LocalDate localDate = LocalDate.of(2021, monthNum, 1);
        try {
            date1 = df.parse(String.valueOf(localDate));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        assert date1 != null;
        cal.setTime(date1);
        
        List<List<Integer>> lists = new LinkedList<>();
        List<Integer> list = new ArrayList<>();
        //当前月份天数
        int dayOfMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        for (int i = 1; i <= dayOfMonth; i++) {
            
            try {
                date1 = df.parse(String.valueOf(localDate));
            } catch (ParseException e) {
                e.printStackTrace();
            }
            cal.setTime(date1);

            int weekNum = cal.get(Calendar.DAY_OF_WEEK_IN_MONTH);
            list.add(weekNum);
            localDate = localDate.plusDays(1);
        }
        

        return null;
    }

    //获取几天前到几天前的时间(过去时间的范围)
    public LocalDate someDay(int startDay, int endDay) {

        return null;
    }


    //    当日时间戳
    public Integer toDayTimeStamp() {
        // 获取明天零点时间戳
        LocalDate localDate = LocalDate.now();
        // 当前日期+1
        localDate = localDate.plusDays(1);


        LocalDateTime dateTime = LocalDateTime.of(localDate.getYear(), localDate.getMonth(), localDate.getDayOfMonth(), 0, 0, 0);
        return Math.toIntExact(dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000);

    }

}
